package com.soriya.nestlive.controller.common;

import com.soriya.nestlive.service.common.UploadService;
import com.soriya.nestlive.util.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/common/upload")
public class UploadController {

    private final UploadService uploadService;

    @Autowired
    public UploadController(UploadService uploadService) {
        this.uploadService = uploadService;
    }

    @PostMapping("/image")
    public Result<?> uploadImage(MultipartFile file) {
        String url = uploadService.uploadImage(file);
        return Result.success(url);
    }

}
